package com.woniuxy.seckill.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * @BelongsProject: hc
 * @BelongsPackage: com.woniuxy.seckill.config
 * @Author: WY
 * @CreateTime: 2022-10-26  11:19
 * @Descriprion: TODO
 * @Version: 1.0
 **/
@Configuration
public class RabbitmqConfiguration {

    //声明交换机
    @Bean
    public TopicExchange topicExchange(){
        return new TopicExchange("topics1");
    }

    //声明队列
    @Bean
    public Queue queueadd(){
        return new Queue("mark1");
    }

    //绑定交换机到队列
    @Bean
    public Binding bindingadd(Queue queueadd,TopicExchange topicExchange){
        return BindingBuilder.bind(queueadd).to(topicExchange).with("#.add");
    }

    @Bean
    public MessageConverter messageConverter(){
        return new Jackson2JsonMessageConverter();
    }
}
